package com.mssh.login.config;

import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: 熳殊沙华
 * @Date: 2025/03/27/17:40
 * @Description: 图形验证码配置
 */
@Configuration
public class KaptchaConfig {

    @Bean
    public DefaultKaptcha kaptcha() {
        DefaultKaptcha kaptcha = new DefaultKaptcha();
        Properties props = new Properties();
        props.put("kaptcha.textproducer.char.length", AuthConfig.getLength());      // 验证码长度
        props.put("kaptcha.image.width", AuthConfig.getWidth());                    // 图片宽度
        props.put("kaptcha.image.height", AuthConfig.getHeight());                  // 图片高度
        Config config = new Config(props);
        kaptcha.setConfig(config);
        return kaptcha;
    }
}
